﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using GameRobot;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace GameRobotControl
{
    public class RobotManager
    {
        public List<Robot> _listRobot = new List<Robot>();
        public Robot _selectedRobot = null;

        public void AddRobot(Robot robot)
        {
            _listRobot.Add(robot);
        }
        public void LoadContent(ContentManager content)
        {
            foreach (Robot robot in _listRobot)
            {
                robot.LoadContent(content);
            }
        }

        public void Update(GameInput gameinput)
        {
            foreach (Robot robot in _listRobot)
            {
                robot.Update(gameinput);
            }
        }
        public void Update(GameTime gameTime)
        {
            foreach (Robot robot in _listRobot)
            {
                robot.Update(gameTime);
            }
        }
        public void Draw(SpriteBatch spriteBatch)
        {
            foreach (Robot robot in _listRobot)
            {
                robot.Draw(spriteBatch);
            }
        }

        public ControlType GetControlType(int id)
        {
            return _listRobot[id]._controlType;
        }

        public List<string> GetActionUsed(int id)
        {
            return _listRobot[id].GetActionUsed();
        }

        //public Vector2 GetRobotPosition(int id)
        //{
        //    return _listRobot[id].GetPos();
        //}

        //public float GetRobotRot(int id)
        //{
        //    return _listRobot[id].GetRot();
        //}

        public List<string> GetListBaseMethod(int id)
        {
            return _listRobot[id].GetListBaseMethod();
        }

        public List<string> GetListMetaMethod(int id)
        {
            return _listRobot[id].GetListMetaMethod();
        }

        public List<string> GetListParam(int id, int idmethod)
        {
            return _listRobot[id].GetListParam(idmethod);
        }

        public void ResetControl(int id)
        {
            _listRobot[id].ResetControl();
        }

        public void ClearControl()
        {
            for (int i = 0; i < _listRobot.Count; i++)
            {
                _listRobot[i].ResetControl();
            }
        }

        public int AddControl(int id, int idmethod, List<object> listparam)
        {
            return _listRobot[id].AddControl(idmethod, listparam);
        }

        public void RunSchedule(int id)
        {
            _listRobot[id].RunSchedule();
        }
    }
}
